<?php
class JobsController extends AppController {
	var $helpers = array('Html', 'Form', 'Javascript');
	var $name = 'Jobs';
	var $components = array('Auth');
	
	function beforeFilter() {
		$this->Auth->allow('view');
	}

	function index() {
		$this->set('jobs', $this->Job->find('all'));
	}

	function view($id = null) {
		$this->Job->id = $id;
		$this->set('job', $this->Job->read());
	}

	function post() {
		if (!empty($this->data)) {
			if ($this->Job->save($this->data)) {
				$this->Session->setFlash('职位已保存');
				$this->redirect(array('action' => 'index'));
			}
		}
	}

	function delete($id) {
		if ($this->Job->delete($id)) {
			$this->Session->setFlash('职位已经删除');
			$this->redirect(array('action' => 'index'));
		}
	}

	function edit($id = null) {
		$this->Job->id = $id;
		if (empty($this->data)) {
			$this->data = $this->Job->read();
		}
		else {
			if ($this->Job->save($this->data)) {
				$this->Session->setFlash('职位已更新');
				$this->redirect(array('action' => 'index'));
			}
		}
	}

}
?>
